
var isdata=0;
var typedata;
var pagindex=0;
var pagesize=10;
var itemIndex = 0;
var id=getUrlParam("id");
mui('body').on('tap','a',function(){document.location.href=this.href;});


function selecthj()
{
    mui.post('/Salary/findByid',
        {
            id:id
        },
        function(data){
            console.log(data);
            if (data.code&&data.object!=null){
                var  item=data.object;
                var money = document.getElementById("money");
                money.innerHTML =item.money+"元";//改变内容

                var phone = document.getElementById("nickname");
                phone.innerHTML =item.nickname;//改变内容

                var kaihuhang = document.getElementById("kaihuhang");
                kaihuhang.innerHTML =item.kaihuhang;//改变内容

                if (item.status!="1")
                {
                    var divshow = document.getElementById("divshow");
                    divshow.style.display="none";
                }
                var yinhangka = document.getElementById("yinhangka");
                yinhangka.innerHTML =item.yinhangka;//改变内容



            }
        },'json'
    );
}

function createFragment(me,itemIndex) {
    selecthj(id);
    var data ={
        upid:id
        }
    var result = '';
    mui.post('/Salary/findByupid', data, function (info) {
        console.log(info);
        var datas = info.object;
        if(datas.length === 0){
            me.lock();
            me.noData();
            me.resetload();
            return;
        }else {
            for (var i = 0; i < datas.length; i++) {
                cold = datas[i];
                result
                    += ''
                    + '    <hgroup class="khfxRow">'
                    + '      <header>下单时间：'+cold['createtime']+'</header>'
                    + '      <div class="mid">'
                    + '        <img class="photo" src="'+cold['userimg']+'" >'
                    + '        <span><label>订单号：</label>'+cold['orderid']+'</span> '
                    + '        <span><label>类型：</label>'+gettixiatype(cold['type'])+'</span> '
                    + '        <span><label>状态：</label>'+gettixiastatus(cold['status'])+'</span> '
                    + '        <span><label>合计id：</label>'+cold["upid"]+'</span> '
                    + '        <span><label>金额：</label>'+cold['money']+'</span> '
                    + '      </div>'
                    + '      <footer style="height: 10px;"></footer>'
                    + '    </hgroup>';
            }
            $('.khfxPane').eq(itemIndex).append(result);
            if(datas.length %10!=0){
                me.$domDown.html(me.opts.domDown.domNoData);
                return;
            }
            else {
                me.resetload();
                me.$domDown.html(me.opts.domDown.domRefresh);
            }

        }
    });

};

function savetype(){
    var dataobj={
        id:id,
        status:2
    }
    mui.post('/Salary/updateOrderType',
        dataobj,
        function(data) {
            if (data.object>0)
            {
                mui.toast('提交成功！');
                window.location.reload();
            }
        },'json'
    )
}


$(function () {
    var itemIndex = 0;
    var tabLoadEndArray = [false, false, false];
    var tabScroolTopArray = [0, 0, 0];
    // dropload
    var dropload = $('.khfxWarp').dropload({
        scrollArea: window,
        domDown: {
            domClass: 'dropload-down',
            domRefresh: '<div class="dropload-refresh">上拉加载更多</div>',
            domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
            domNoData: '<div class="dropload-noData">已无数据</div>'
        },
        loadDownFn: function (me) {
            setTimeout(function () {
                createFragment(me, itemIndex);
            }, 500);
        }
    });



});